package com.wxx.main;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPClient;

public class MainFtp {

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		String weixx = "This is weixx!";
		byte[] bt = weixx.getBytes();
		InputStream is = new ByteArrayInputStream(bt);
		FTPClient ftpClient = new FTPClient();
		// 22.188.12.160:21:root:pass01!:/usr/wxx
		try {
			ftpClient.connect("22.188.12.160", 21);
			ftpClient.login("root", "pass01!");
			ftpClient.setControlEncoding("UTF-8");
			ftpClient.changeWorkingDirectory("/usr/wxx");
			//ftpClient.deleteFile("wxx");
			//ftpClient.storeFile("wxx", is);
			InputStream ist=ftpClient.retrieveFileStream("wxx");
			StringBuffer sb =new StringBuffer();
			if(ist!=null)
			{
				BufferedReader br = new BufferedReader(new InputStreamReader(ist));
				String st = "";
				while((st=br.readLine())!=null)
				{
					sb.append(st);
				}
			}
			File fl = new File("d:/x.log");
			System.out.println("3333333333333333333333"+sb);
			ftpClient.logout();
			ftpClient.disconnect();
		} catch (SocketException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
